clear
PS3='选择你要下载的版本或者选项： '
neihe=("Openserver" "java17" "Quit" "openeula" "Delete" "minecraftjavaserver" "spigot" "paper")
select fav in "${neihe[@]}"; do
    case $fav in
        "Quit")
	    echo "已退出"
	    exit
	    ;;
        "minecraftjavaserver")
            clear
            echo "速度较慢，请耐心等待"
            echo "正在安装我的世界官方java版服务器内核"
            cd ..
            mkdir server
            cd ./server
            wget -O server.jar https://piston-data.mojang.com/v1/objects/c9df48efed58511cdd0213c56b9013a7b5c9ac1f/server.jar
            cd ..
            cd ./cd
            echo "安装完毕，按任意键退出"
            read -n 1 option
            clear
            exit
            ;;

        "paper")
            clear
            echo "正在安装paper服务器内核"
            cd ..
            mkdir server
            cd ./server
            wget -O server.jar https://api.papermc.io/v2/projects/paper/versions/1.19.3/builds/386/downloads/paper-1.19.3-386.jar
            cd ..
            cd ./cd
            echo "安装完毕，按任意键退出"
            read -n 1 option
            clear
            exit
            ;;

        "spigot")
            clear
            echo "正在安装spigot服务器内核"
            cd ..
            mkdir server
            cd ./server
            wget -O server.jar https://download.getbukkit.org/spigot/spigot-1.19.3.jar
            cd ..
            cd ./cd
            echo "安装完毕，按任意键退出"
            read -n 1 option
            clear
            exit
            ;;

        "java17")
            cd ..
	          wget -O java.tar.gz https://download.oracle.com/java/17/archive/jdk-17.0.6_linux-x64_bin.tar.gz
	          tar -zxvf java.tar.gz
	          mv jdk-17.0.6 java
	          cd ./cd
	          exit
            ;;

        "Openserver")
	          cd ../server
	          chmod +x ./java/bin/java
	          ./java/bin/jar -jar ./server.jar
	          echo -e "如果自动退出，请到菜单内快捷修改eula文件"
	          cd ../cd
	          exit
            ;;

        "eula")
            cd ../server
            nano ./eula.txt
            cd ./cd
            exit
            ;;

        "Delete")
            echo "按人任意键将会删除服务器文件"
            read -n 1 option
            echo "真的确定要删除服务器文件吗，真的是永久删除"
            read -n 1 option
            cd ..
            rm -rf ./server
            cd ./cd
            exit
            ;;

        *) echo "你输入错了！ $REPLY";;
    esac
done
